﻿using ApiLib.AppStart;
using ApiLib.Utils;
using SqlSugar;

namespace ApiLib.Models;

/// <summary>
/// 请求日志
/// </summary>
[Tenant(GlobalConstants.MainDbConfigId), SugarTable(TableName = "sys_request_log")]
public class SysRequestLog
{
    /// <summary>
    ///  
    ///</summary>
    [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
    public int Id { get; set; }

    /// <summary>
    /// 控制器、路由信息 
    ///</summary>
    [SugarColumn(ColumnName = "descriptor")]
    public string Descriptor { get; set; }

    /// <summary>
    /// 请求路径 
    ///</summary>
    [SugarColumn(ColumnName = "path")]
    public string Path { get; set; }
    
    /// <summary>
    /// 请求体 
    ///</summary>
    [SugarColumn(ColumnName = "body")]
    public string Body { get; set; }
    
    /// <summary>
    /// 请求体 
    ///</summary>
    [SugarColumn(ColumnName = "result")]
    public string Result { get; set; }

    /// <summary>
    /// 是否成功 
    ///</summary>
    [SugarColumn(ColumnName = "succeed")]
    public bool Succeed { get; set; }

    /// <summary>
    /// IPV4地址 
    ///</summary>
    [SugarColumn(ColumnName = "ip")]
    public string Ip { get; set; }
    
    /// <summary>
    /// 用户 
    ///</summary>
    [SugarColumn(ColumnName = "user")]
    public string User { get; set; }

    /// <summary>
    /// 开始时间 
    ///</summary>
    [SugarColumn(ColumnName = "start_time")]
    public DateTime StartTime { get; set; }

    /// <summary>
    /// 结束时间 
    ///</summary>
    [SugarColumn(ColumnName = "end_time")]
    public DateTime EndTime { get; set; }

    /// <summary>
    /// 时间差（毫秒） 
    ///</summary>
    [SugarColumn(ColumnName = "time_span")]
    public double TimeSpan { get; set; }
}